package com.ycw.xiaocai.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.ycw.bean.Comments;
import com.ycw.bean.Projects;
import com.ycw.service.xiaocai.XiaoCaiService;
import com.ycw.util.Msg;

@Controller
public class XiaoCaiController {
	
	@Autowired
	XiaoCaiService xiaocaiService;
	
	//查询所有评论信息  分页展示
	@RequestMapping("/getAllComments")
	@ResponseBody
	public Msg getAllComments(@RequestParam(value="page",defaultValue="1")Integer page){
		//引入 pageHelper
		PageHelper.startPage(page, 10);
		List<Comments> list=xiaocaiService.getALLComments(); 

		//分页插件
		PageInfo pageInfo = new PageInfo(list);

		return Msg.success().add("pageInfo", pageInfo);
		
	}
	
	//删除评论
	@RequestMapping("/deleteCommentsById")
	@ResponseBody
	public Msg deleteComments(Comments comments) {
		xiaocaiService.deleteComments(comments);
		return Msg.success();
	}
	
	//项目名称、项目发起人、项目状态、项目分类
	@RequestMapping("/getAllProjectAndType")
	@ResponseBody
	public Msg getAllProjectAndType(@RequestParam(value="page",defaultValue="1")Integer page,String psName,String usName,Integer psType,Integer pstId) {
		PageHelper.startPage(page, 10);
		List<Projects> list=xiaocaiService.getAllProjectAndType(psName,usName,psType,pstId);
		//分页插件
		PageInfo pageInfo = new PageInfo(list);

		return Msg.success().add("pageInfo", pageInfo);
				
	}
	
	//项目分类功能
	//项目类型 1:教育助学 2:爱心环保 3:扶贫助 4:公益创业  5:公益活动
	

}
